//*************************************************************************************
//* 作    者： zouhunter
//* 创建时间： 2021-11-09 05:02:12
//* 描    述： 播放音效

//* ************************************************************************************
using UnityEngine;

public class IDSoundPlayBehaviour : MonoBehaviour
{
    [SerializeField]
    protected int m_soundId;
    [SerializeField]
    protected bool m_3d;
    [SerializeField]
    protected Vector3 m_localPos;
    [SerializeField]
    protected bool m_playOnEnable;

    public int SoundId => m_soundId;

    private void OnEnable()
    {
        if (m_playOnEnable)
        {
            Play();
        }
    }

    public void Play()
    {
        Play(m_soundId);
    }

    public void Play(int soundId)
    {
        if (m_3d)
        {
            SoundAgent.Instance.PlayAudioById(soundId, transform.TransformPoint(m_localPos));
        }
        else
        {
            SoundAgent.Instance.PlayAudioById(soundId);
        }
    }
}
